﻿<!--#include file="../lib/base.asp"-->
<!--#include file="../theme.asp"-->
<%
''' 搜索筛选ajax服务端
''' ==================================================================
''' 版权所有 http://www.ahseo.cc
''' ------------------------------------------------------------------
''' 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用；
''' 未经授权不允许对程序代码以任何形式任何目的的再发布。
''' ==================================================================
''' 编写: 寻云
''' 修改：寻云 in 2015.12

dim theme_load:theme_load="ajax/ajaxsearch.asp"


dim MyBoard:MyBoard=sdcms.enhtml(sdcms.fget("MyBoard",0))'是否收藏

dim FreeText:FreeText=sdcms.enhtml(sdcms.fget("FreeText",0))'搜索key
dim Manufacturer:Manufacturer=sdcms.getint(sdcms.fget("Manufacturer",0),0)'品牌
dim skip:skip=sdcms.getint(sdcms.fget("skip",0),0)'分页
dim CategoryId:CategoryId=sdcms.enhtml(sdcms.fget("CategoryId",0))'BIM对象分类
dim MaterialId:MaterialId=sdcms.enhtml(sdcms.fget("MaterialId",0))'材料
dim BuildingTypeId:BuildingTypeId=sdcms.enhtml(sdcms.fget("BuildingTypeId",0))'构建类型
dim FunctionalSpaceId:FunctionalSpaceId=sdcms.enhtml(sdcms.fget("FunctionalSpaceId",0))'功能空间
dim FileTypeId:FileTypeId=sdcms.enhtml(sdcms.fget("FileTypeId",0))'文件类型
dim ContentTypeId:ContentTypeId=sdcms.enhtml(sdcms.fget("ContentTypeId",0))'类型
dim sql_where:sql_where="classid=1 and islock=1"

if len(FreeText)>0 then
sql_where=sql_where&" and title like '%"&FreeText&"%'"
end if



dim userid:userid=0


if sdcms.is_login then
dim userdata,i,idata,inid
	userdata=sdcms.userinfo
	userid=userdata(0)
if MyBoard="true" then
idata=sdcms.db.dbload("","userid,contentid","sd_user_favorite","userid="&userid&"","id")
if ubound(idata)<0 then
sql_where=sql_where&"and 1=2"
else
if ubound(idata,2)=0 then
sql_where=sql_where&"and id="&idata(1,0)&""
else
for i=0 to ubound(idata,2)
if i=0 then
inid=idata(1,i)
else
inid=inid&","&idata(1,i)
end if
next
sql_where=sql_where&"and id in("&inid&")"
end if

end if
end if
end if
			



if Manufacturer<>0  then
sql_where=sql_where&" and userid ="&Manufacturer&""
end if

if len(CategoryId)>0 then
sql_where=sql_where&" and CategoryId like '%"&CategoryId&"%'"
end if
if len(MaterialId)>0 then
sql_where=sql_where&" and MaterialId like '%"&MaterialId&"%'"
end if

if len(BuildingTypeId)>0 then
sql_where=sql_where&" and BuildingTypeId like '%"&BuildingTypeId&"%'"
end if

if len(FunctionalSpaceId)>0 then
sql_where=sql_where&" and MaterialId like '%"&FunctionalSpaceId&"%'"
end if

if len(FileTypeId)>0 then
sql_where=sql_where&" and FileTypeId like '%"&FileTypeId&"%'"
end if
if len(ContentTypeId)>0 then
sql_where=sql_where&" and ContentTypeId like '%"&ContentTypeId&"%'"
end if

function IsBoardElement(byval t0,byval t1)
IsBoardElement="false"
if sdcms.db.dbcount("sd_user_favorite","contentid="&t0&" and userid="&t1&"")>0 then
IsBoardElement="true"
end if		
end function

if skip<>0 then
sql_where=sql_where&"and id not in(select top "&skip&" id from sd_content where "&sql_where&" order by id) "
end if

'筛选
dim sql_order:sql_order=""
sql_order="lastupdate desc,id desc"

dim root:root=sdcms.enhtml(sdcms.fget("root",0))
	sdcms.show theme_load,""

	sdcms.db.dbclose
%>